<template>
  <div>
    <headTop></headTop>
    <visitor-pie :pieData="pieData"></visitor-pie>
  </div>
</template>

<script>
import headTop from "@/components/headTop";
import visitorPie from "@/components/visitorPie";
import API from '@/api'
export default {
  name: "Visitor",
  data() {
    return {
      pieData: {}
    };
  },
  components: {
    headTop,
    visitorPie
  },
  mounted() {
    this.initData();
  },
  methods: {
    async initData() {
      try {
        const res = await API.getUserCity();
        if (res.status == 1) {
          this.pieData = res.user_city;
        } else {
          throw new Error(res);
        }
      } catch (err) {
        console.log("获取用户分布信息失败", err);
      }
    }
  }
};
</script>